﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace fhe
{
  using core;
  using math;
  namespace physics
  {
    public interface ICollidable
    {
      Circle GetBoundingCircle();

      bool Inside(Vec2 v);

      void OffsetTo(Vec2 v, Vec2? dir, out Vec2 offset, out List<PointMass> points);

      double Friction { get; }

      void Collide(ICollidable collidable);
    }

    public class World : Node, IUpdatable
    {
      public void Update(TimeSpan dt)
      {
        List<ICollidable> collidables = GetDescendantsOfType<ICollidable>();
        for (int i = 0; i < collidables.Count; ++i)
        {
          for (int j = 0; j < collidables.Count; ++j)
          {
            if (i != j)
            {
              collidables[i].Collide(collidables[j]);
            }
          }
        }
      }
    }
  }
}
